package edu.zju.gis.dbfg.model.base;

import edu.zju.gis.dbfg.model.PyramidConfig;
import org.geotools.referencing.CRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import java.io.Serializable;

public class Constant implements Serializable {

    //public final static String ES_IP = "192.168.1.5,192.168.1.6,192.168.1.7";
    public final static String ES_IP = "10.2.40.51,10.2.40.52,10.2.40.53,10.2.40.54";
    public final static Integer ES_IP_PORT = 9200;
    public final static Integer ES_SEARCH_SCROLL_SIZE = 2000;
    public final static long ES_SEARCH_SCROLL_INTERVAL = 5L;

    public final static String CRS_3857 = "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\", \n" +
            "  GEOGCS[\"GCS_WGS_1984\", \n" +
            "    DATUM[\"D_WGS_1984\", \n" +
            "      SPHEROID[\"WGS_1984\", 6378137.0, 298.257223563]], \n" +
            "    PRIMEM[\"Greenwich\", 0.0], \n" +
            "    UNIT[\"degree\", 0.017453292519943295], \n" +
            "    AXIS[\"Longitude\", EAST], \n" +
            "    AXIS[\"Latitude\", NORTH]], \n" +
            "  PROJECTION[\"Popular Visualisation Pseudo Mercator\"], \n" +
            "  PARAMETER[\"semi_minor\", 6378137.0], \n" +
            "  PARAMETER[\"latitude_of_origin\", 0.0], \n" +
            "  PARAMETER[\"central_meridian\", 0.0], \n" +
            "  PARAMETER[\"scale_factor\", 1.0], \n" +
            "  PARAMETER[\"false_easting\", 0.0], \n" +
            "  PARAMETER[\"false_northing\", 0.0], \n" +
            "  UNIT[\"m\", 1.0], \n" +
            "  AXIS[\"x\", EAST], \n" +
            "  AXIS[\"y\", NORTH]]";

    public final static String CRS_4326 = "GEOGCS[\"GCS_WGS_1984\", \n" +
            "  DATUM[\"D_WGS_1984\", \n" +
            "    SPHEROID[\"WGS_1984\", 6378137.0, 298.257223563]], \n" +
            "  PRIMEM[\"Greenwich\", 0.0], \n" +
            "  UNIT[\"degree\", 0.017453292519943295], \n" +
            "  AXIS[\"Longitude\", EAST], \n" +
            "  AXIS[\"Latitude\", NORTH]]";

//    public final static String CRS_4528 = "GEOGCS[\"GCS_China_Geodetic_Coordinate_System_2000\"," +
//            "DATUM[\"D_China_2000\"," +
//            "SPHEROID[\"CGCS2000\",6378137.0,298.257222101]]," +
//            "PRIMEM[\"Greenwich\",0.0]," +
//            "UNIT[\"Degree\",0.0174532925199433]]";

    public final static Integer DEFAULT_Z_LEVEL = 14;

    public final static CoordinateReferenceSystem DEFAULT_CRS () throws Exception {
        return CRS.parseWKT(CRS_4326);
    }

    public final static CoordinateReferenceSystem CRS_4326 () throws Exception {
        return CRS.parseWKT(CRS_4326);
    }

    public final static PyramidConfig DEFAULT_PYRAMID_CONFIG () throws Exception {
        return new PyramidConfig.PyramidConfigBuilder()
                .setBaseMapEnv(-20026376.39, 20026376.39, -20048966.10, 20048966.10)
                .setCrs(DEFAULT_CRS())
                .setzLevelRange(DEFAULT_Z_LEVEL-1, DEFAULT_Z_LEVEL)
                .build();
    }

    public final static PyramidConfig PYRAMID_CONFIG_4326 () throws Exception {
        return new PyramidConfig.PyramidConfigBuilder()
                .setBaseMapEnv(-180,180, -90,90)
                .setCrs(CRS_4326())
                .setzLevelRange(DEFAULT_Z_LEVEL-1, DEFAULT_Z_LEVEL)
                .build();
    }

}
